#ifndef MAINSCENE_H
#define MAINSCENE_H

#include "camera.h"
#include "mapmanager.h"
#include <QWidget>
#include <QCompleter>
#include <QStringListModel>
#include <QElapsedTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainScene; }
QT_END_NAMESPACE

class MainScene : public QWidget
{
    Q_OBJECT

public:
    MainScene(QWidget *parent = nullptr);
    ~MainScene();

private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_6_clicked();

    void on_pushButton_storage_clicked();

    void on_pushButton_toMenu_clicked();

    void on_pushButton_7_clicked();

    void on_radioButton_clicked(bool checked);

    void on_radioButton_2_clicked(bool checked);

    void on_pushButton_10_clicked();

    void on_radioButton_4_clicked(bool checked);

    void on_radioButton_3_clicked(bool checked);

    void on_pushButton_9_clicked();

    void on_pushButton_8_clicked();

    void createPaths(const QStringList& list);
private:
    void paintEvent(QPaintEvent *) override;

    void resizeEvent(QResizeEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;

    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

    void showEvent(QShowEvent *event) override;

    void initTimer();
private:  
    Camera _camera;

    bool _mousepressed = false;
    QPoint _oldpos;
    QPoint _oldmousepos;

    QElapsedTimer etimer;
    QSharedPointer<Node> _node;
    QString _node_id, _src_id, _dst_id;
    bool _nodecanmove = false;

    QTimer* _timer_updateui = nullptr;
    QTimer* _timer_wheel = nullptr;
    int _d_wheel = 0;

    QCompleter *completer;
    QStringListModel *model;

    QHash<int, QStringList> _paths;
    int _select;

    Ui::MainScene *ui;
};
#endif // MAINSCENE_H
